//引入插件
var gulp = require('gulp');
var connect = require('gulp-connect');
var {createProxyMiddleware}=require('http-proxy-middleware')

//使用connect启动一个Web服务器

gulp.task('proxyServer', function() {
    connect.server({
        root: 'app',
        livereload: true,
        host: '0.0.0.0',
        port:process.env.PORT || 8009,
        middleware: function(connect, opt) {
            return [
                /*createProxyMiddleware('/file',  {
                    target: 'http://127.0.0.1:5555',//代理的目标地址
                    changeOrigin:true,//
                })*/
                createProxyMiddleware('/third/',  {
                    target: 'http://test.ningmengcar.com:33333',//代理的目标地址
                    changeOrigin:true,//
                })
            ]
        }

    });
});

//运行Gulp时，默认的Task
gulp.task('default', ['proxyServer']);
